package com.lingshu.app.model;

import java.util.List;

/**
 * @author 于定金
 * @version 1.0
 * @Date 2024/1/8 14:55
 * @Description
 */
public class PagedList<T> {
    private int pageIndex;
    private int pageSize;
    private int totalPage;
    private int totalCount;
    private boolean hasPreviousPage;
    private boolean hasNextPage;
    private List<T> data;

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setHasPreviousPage(boolean hasPreviousPage) {
        this.hasPreviousPage = hasPreviousPage;
    }

    public boolean getHasPreviousPage() {
        return hasPreviousPage;
    }

    public void setHasNextPage(boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
    }

    public boolean getHasNextPage() {
        return hasNextPage;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public List<T> getData() {
        return data;
    }

    public PagedList() {
    }

    public PagedList(int totalCount, int pageSize, List<T> data) {
        this.pageIndex = 1;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.totalPage = (totalCount + pageSize - 1) / pageSize;
        this.data = data;
        this.hasPreviousPage = this.pageIndex > 1;
        this.hasNextPage = this.pageIndex < this.totalPage;
    }

    @Override
    public String toString() {
        return "PagedList{" + "pageIndex=" + pageIndex + ", pageSize=" + pageSize + ", totalPage=" + totalPage + ", totalCount=" + totalCount + ", hasPreviousPage=" + hasPreviousPage + ", hasNextPage=" + hasNextPage + ", data=" + data + '}';
    }
}
